layui.use(['table', 'form', 'vip_table', 'jquery', 'fms_util', 'element'], function () {
    // 操作对象
    var form = layui.form,
        table = layui.table,
        vipTable = layui.vip_table,
        fmsUtil = layui.fms_util,
        element = layui.element,
        $ = layui.jquery;

    function test(){
        var data ={
            data:{
                cpu:[
                    {userRate:"良好",systemUseRate:"20%",totalUseRate:"30%",unusedRate:"50%"}
                ],
                disks:[
                    {name:"C盘",total:"200M",unused:"300M",used:"500M"}
                ],
                memory:[
                    {used:"200M",unusedRate:"200M",unused:"300M",total:"500M"}
                ]
            }

        }
        cpuTable(data);
        diskTable(data);
        memoryTable(data);
        dataBase(data);
    }
    test();
    window.setInterval(test,5000);

    var tableIns = {};

    function cpuTable(data) {
        console.log(data.data.cpu)
        tableIns = vipTable.bdTable({
            table: table,
            elem: "#cpuTable",
            cols: [[
                {type: 'numbers', title: '序',width:'5%', align: 'center'},
                {field: 'userRate', title: '用户使用情况',width:'24%', align: 'center'},
                {field: 'systemUseRate', title: '系统使用情况',width:'24%',align: 'center'},
                {field: 'totalUseRate', title: '总体使用情况',width:'22%',align: 'center'},
                {field: 'unusedRate', title: '剩余',width:'22%',align: 'center'}
            ]],
            data:data.data.cpu,
            done: function (res, curr, count) {
                // console.log(res);
            }
        });
    }
    function diskTable(data) {
        tableIns = vipTable.bdTable({
            table: table,
            elem: "#diskTable",
            cols: [[
                {type: 'numbers', title: '序',width:'8%', align: 'center'},
                {field: 'name', title: '磁盘名称',width:'24%', align: 'center'},
                {field: 'total', title: '磁盘总量(MB)',width:'24%', align: 'center'},
                {field: 'unused', title: '磁盘剩余量(MB)',width:'20%', align: 'center'},
                {field: 'used', title: '磁盘使用容量(MB)',width:'20%', align: 'center'}
            ]],
            data:data.data.disks,
            done: function (res, curr, count) {
                // console.log(res);
            }
        });
    }
    function memoryTable(data) {
        tableIns = vipTable.bdTable({
            table: table,
            elem: "#memoryTable",
            cols: [[
                {type: 'numbers', title: '序',width:'5%', align: 'center'},
                {field: 'total', title: '磁盘总量(MB)',width:'15%',align: 'center'},
                {field: 'unused', title: '磁盘剩余量(MB)',width:'18%',align: 'center'},
                {field: 'unusedRate', title: '剩余(%)',width:'18%',align: 'center'},
                {field: 'used', title: '磁盘使用容量(MB)',width:'20%',align: 'center'},
                {field: 'unused', title: '已使用(%)',width:'20%',align: 'center'}
            ]],
            data:data.data.memory,
            done: function (res, curr, count) {
                // console.log(res);
            }
        });
    }
    function dataBase(data) {
        tableIns = vipTable.bdTable({
            table: table,
            elem: "#dataBase",
            cols: [[
                {type: 'numbers', title: '序',width:'5%', align: 'center'},
                {field: 'connectCount', title: '连接数',align: 'center'},
                {field: 'runCount', title: '运行数',align: 'center'},
                {field: 'totalData', title: '最大连接数',align: 'center'},
                {field: 'maxConnectCount', title: '数据量(MB)',align: 'center'},
                {field: 'indexCount', title: '索引量(MB)',align: 'center'},
                {field: 'unusedDisk', title: '磁盘剩余量(MB)',align: 'center'}
            ]],
            data:data.data.dbResource,
            done: function (res, curr, count) {
                // console.log(res);
            }
        });
    }
});